package com.dongzili.demo.common.config.es;

import cn.hutool.extra.spring.SpringUtil;
import org.dromara.easyes.core.kernel.BaseEsMapper;

public class EsUtils {

    public static <T> BaseEsMapper<T> getMapper(final Class<T> t) {
        return SpringUtil.getBean(getBeanName(t) + "AutoEsMapper");
    }

    /**
     * 获取bean名称
     * @param t
     * @return
     */
    private static <T> String getBeanName(final Class<T> t) {
        return t.getSimpleName().substring(0, 1).toLowerCase() + t.getSimpleName().substring(1);
    }

}
